<!doctype html>



  


<html class="theme-next mist use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/vendors/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/vendors/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="正则," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.0.1" />






<meta name="description" content="0. 正则实例通俗说明
例1：校验是否全由数字组成  /^[0-9]{1,20}$/


^ 表示打头的字符要匹配紧跟^后面的规则$ 表示打头的字符要匹配紧靠$前面的规则[ ] 中的内容是可选字符集[0-9] 表示要求字符范围在0-9之间{1,20}表示数字字符串长度合法为1到20，即为[0-9]中的字符出现次数的范围是1到20次。/^ 和 $/成对使用应该是表示要求整个字符串完全匹配定义的规则，">
<meta property="og:type" content="article">
<meta property="og:title" content="正则笔记">
<meta property="og:url" content="http://YoungHearts.oschina.io/20151028/正则笔记/index.html">
<meta property="og:site_name" content="YangJ's Blog">
<meta property="og:description" content="0. 正则实例通俗说明
例1：校验是否全由数字组成  /^[0-9]{1,20}$/


^ 表示打头的字符要匹配紧跟^后面的规则$ 表示打头的字符要匹配紧靠$前面的规则[ ] 中的内容是可选字符集[0-9] 表示要求字符范围在0-9之间{1,20}表示数字字符串长度合法为1到20，即为[0-9]中的字符出现次数的范围是1到20次。/^ 和 $/成对使用应该是表示要求整个字符串完全匹配定义的规则，">
<meta property="og:updated_time" content="2016-11-01T03:14:42.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="正则笔记">
<meta name="twitter:description" content="0. 正则实例通俗说明
例1：校验是否全由数字组成  /^[0-9]{1,20}$/


^ 表示打头的字符要匹配紧跟^后面的规则$ 表示打头的字符要匹配紧靠$前面的规则[ ] 中的内容是可选字符集[0-9] 表示要求字符范围在0-9之间{1,20}表示数字字符串长度合法为1到20，即为[0-9]中的字符出现次数的范围是1到20次。/^ 和 $/成对使用应该是表示要求整个字符串完全匹配定义的规则，">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Mist',
    sidebar: {"position":"left","display":"always"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: 0,
      author: '博主'
    }
  };
</script>

  <title> 正则笔记 | YangJ's Blog </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  



  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?783106e6f997bc237c1e1b160cedbe88";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>








  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">YangJ's Blog</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">记录我的学习工作点滴</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="#" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup">
 <span class="search-icon fa fa-search"></span>
 <input type="text" id="local-search-input">
 <div id="local-search-result"></div>
 <span class="popup-btn-close">close</span>
</div>


    </div>
  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                正则笔记
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2015-10-28T12:09:47+08:00" content="2015-10-28">
              2015-10-28
            </time>
          </span>

          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/20151028/正则笔记/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="20151028/正则笔记/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          
          
             <span id="/20151028/正则笔记/" class="leancloud_visitors" data-flag-title="正则笔记">
               &nbsp; | &nbsp;
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               <span class="post-meta-item-text">阅读次数 </span>
               <span class="leancloud-visitors-count"></span>
              </span>
          

          
              &nbsp; | &nbsp;
              <span class="page-pv"><i class="fa fa-file-o"></i>
              <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>
              </span>
          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h4 id="0-正则实例通俗说明"><a href="#0-正则实例通俗说明" class="headerlink" title="0. 正则实例通俗说明"></a>0. 正则实例通俗说明</h4><ul>
<li>例1：校验是否全由数字组成<br>  <code>/^[0-9]{1,20}$/</code></li>
</ul>
<blockquote>
<p>^ 表示打头的字符要匹配紧跟^后面的规则<br>$ 表示打头的字符要匹配紧靠$前面的规则<br>[ ] 中的内容是可选字符集<br>[0-9] 表示要求字符范围在0-9之间<br>{1,20}表示数字字符串长度合法为1到20，即为[0-9]中的字符出现次数的范围是1到20次。<br>/^ 和 $/成对使用应该是表示要求整个字符串完全匹配定义的规则，而不是只匹配字符串中的一个子串。</p>
</blockquote>
<ul>
<li>例2：校验登录名：只能输入5-20个以字母开头、可带数字、“_”、“.”的字串</li>
</ul>
<p><code>/^[a-zA-Z]{1}([a-zA-Z0-9]|[._]){4,19}$/</code></p>
<blockquote>
<p>^[a-zA-Z]{1} 表示第一个字符要求是字母。<br>([a-zA-Z0-9]|[.<em>]){4,19} 表示从第二位开始（因为它紧跟在上个表达式后面）的一个长度为4到9位的字符串，它要求是由大小写字母、数字或者特殊字符集[.</em>]组成。</p>
</blockquote>
<ul>
<li>校验纯中文字符<br><code>/^[\u4E00-\u9FA5]+$/</code></li>
</ul>
<h4 id="1-exec-正则通用匹配公式"><a href="#1-exec-正则通用匹配公式" class="headerlink" title="1. exec() 正则通用匹配公式"></a>1. exec() 正则通用匹配公式</h4><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line">&lt;input  onblur=<span class="string">"chkValue(this)"</span> value=<span class="string">""</span> type=<span class="string">"text"</span>/&gt;</div><div class="line">&lt;script type="text/javascript"&gt;</div><div class="line">    //校验密码：只能输入6-20个字母、数字、下划线</div><div class="line">    function chkValue(txt) &#123;</div><div class="line">        var reg=/^(\w)&#123;6,12&#125;$/;</div><div class="line">        if(reg.exec(txt.value))&#123;</div><div class="line">            console.log('通过')</div><div class="line">        &#125;else&#123;</div><div class="line"></div><div class="line">            console.log('不通过')</div><div class="line">        &#125;</div><div class="line">    &#125;</div><div class="line">&lt;/script&gt;</div></pre></td></tr></table></figure>
<h4 id="2-匹配N个x后的所有字符"><a href="#2-匹配N个x后的所有字符" class="headerlink" title="2. 匹配N个x后的所有字符"></a>2. 匹配N个x后的所有字符</h4><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> reg = <span class="regexp">/[^\-]*\-[^\-]*\-(.*)/g</span>;</div><div class="line"><span class="keyword">var</span> str = <span class="string">"2015-09-11-12"</span>;</div><div class="line">str = str.replace(reg, <span class="string">"$1"</span>);</div><div class="line"><span class="built_in">console</span>.log(str);</div><div class="line">结果：<span class="number">11</span><span class="number">-12</span></div></pre></td></tr></table></figure>
<h4 id="3、其他收藏备份"><a href="#3、其他收藏备份" class="headerlink" title="3、其他收藏备份"></a>3、其他收藏备份</h4><p>“^\d+$”　　//非负整数（正整数 + 0）<br>“^[0-9]<em>[1-9][0-9]</em>$”　　//正整数<br>“^((-\d+)|(0+))$”　　//非正整数（负整数 + 0）<br>“^-[0-9]<em>[1-9][0-9]</em>$”　　//负整数<br>“^-?\d+$”　　　　//整数<br>“^\d+(.\d+)?$”　　//非负浮点数（正浮点数 + 0）<br>“^(([0-9]+.[0-9]<em>[1-9][0-9]</em>)|([0-9]<em>[1-9][0-9]</em>.[0-9]+)|([0-9]<em>[1-9][0-9]</em>))$”　　//正浮点数<br>“^((-\d+(.\d+)?)|(0+(.0+)?))$”　　//非正浮点数（负浮点数 + 0）<br>“^(-(([0-9]+.[0-9]<em>[1-9][0-9]</em>)|([0-9]<em>[1-9][0-9]</em>.[0-9]+)|([0-9]<em>[1-9][0-9]</em>)))$”　　//负浮点数<br>“^(-?\d+)(.\d+)?$”　　//浮点数<br>“^[A-Za-z]+$”　　//由26个英文字母组成的字符串<br>“^[A-Z]+$”　　//由26个英文字母的大写组成的字符串<br>“^[a-z]+$”　　//由26个英文字母的小写组成的字符串<br>“^[A-Za-z0-9]+$”　　//由数字和26个英文字母组成的字符串<br>“^\w+$”　　//由数字、26个英文字母或者下划线组成的字符串<br>“^[\w-]+(.[\w-]+)<em>@[\w-]+(.[\w-]+)+$”　　　　//email地址<br>“^[a-zA-z]+://(\w+(-\w+)</em>)(.(\w+(-\w+)<em>))</em>(\?\S*)?$”　　//url<br>/^(d{2}|d{4})-((0([1-9]{1}))|(1[1|2]))-((<a href="[1-9]{1}">0-2</a>)|(3[0|1]))$/   //  年-月-日<br>/^((0([1-9]{1}))|(1[1|2]))/((<a href="[1-9]{1}">0-2</a>)|(3[0|1]))/(d{2}|d{4})$/   // 月/日/年<br>“^([w-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([w-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)$”   //Emil<br>“(d+-)?(d{4}-?d{7}|d{3}-?d{8}|^d{7,8})(-d+)?”     //电话号码<br>“^(d{1,2}|1dd|2[0-4]d|25[0-5]).(d{1,2}|1dd|2[0-4]d|25[0-5]).(d{1,2}|1dd|2[0-4]d|25[0-5]).(d{1,2}|1dd|2[0-4]d|25[0-5])$”   //IP地址</p>
<p>^([0-9A-F]{2})(-[0-9A-F]{2}){5}$   //MAC地址的正则表达式<br>^[-+]?\d+(.\d+)?$  //值类型正则表达式</p>
<p>5.javascript正则表达式检验<br>//校验是否全由数字组成<br>function isDigit(s)<br>{<br>var patrn=/^[0-9]{1,20}$/;<br>if (!patrn.exec(s)) return false<br>return true<br>}</p>
<p>//校验登录名：只能输入5-20个以字母开头、可带数字、“<em>”、“.”的字串<br>function isRegisterUserName(s)<br>{<br>var patrn=/^[a-zA-Z]{1}([a-zA-Z0-9]|[.</em>]){4,19}$/;<br>if (!patrn.exec(s)) return false<br>return true<br>}</p>
<p>//校验用户姓名：只能输入1-30个以字母开头的字串<br>function isTrueName(s)<br>{<br>var patrn=/^[a-zA-Z]{1,30}$/;<br>if (!patrn.exec(s)) return false<br>return true<br>}</p>
<p>//校验密码：只能输入6-20个字母、数字、下划线<br>function isPasswd(s)<br>{<br>var patrn=/^(\w){6,20}$/;<br>if (!patrn.exec(s)) return false<br>return true<br>}</p>
<p>//校验普通电话、传真号码：可以“+”开头，除数字外，可含有“-”<br>function isTel(s)<br>{<br>//var patrn=/^[+]{0,1}(\d){1,3}[ ]?([-]?(\d){1,12})+$/;<br>var patrn=/^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/;<br>if (!patrn.exec(s)) return false<br>return true<br>}</p>
<p>//校验手机号码：必须以数字开头，除数字外，可含有“-”<br>function isMobil(s)<br>{<br>var patrn=/^1[3|4|5|7|8]\d{9}$/;<br>if (!patrn.exec(s)) return false<br>return true<br>}</p>
<p>//校验邮政编码<br>function isPostalCode(s)<br>{<br>//var patrn=/^[a-zA-Z0-9]{3,12}$/;<br>var patrn=/^[a-zA-Z0-9 ]{3,12}$/;<br>if (!patrn.exec(s)) return false<br>return true<br>}</p>
<p>//校验搜索关键字<br>function isSearch(s)<br>{<br>var patrn=/^[^<code>~!@#$%^&amp;*()+=|\\\][\]\{\}:;\&#39;\,.&lt;&gt;/?]{1}[^</code>~!@$%^&amp;()+=|\][]{}:;\’\,.&lt;&gt;?]{0,19}$/;<br>if (!patrn.exec(s)) return false<br>return true<br>}</p>
<p>function isIP(s) //by zergling<br>{<br>var patrn=/^[0-9.]{1,20}$/;<br>if (!patrn.exec(s)) return false<br>return true<br>}</p>
<p>/<strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>*</strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></p>
<ul>
<li>FUNCTION: isBetween</li>
<li>PARAMETERS: val AS any value</li>
<li>lo AS Lower limit to check</li>
<li>hi AS Higher limit to check</li>
<li>CALLS: NOTHING</li>
<li>RETURNS: TRUE if val is between lo and hi both inclusive, otherwise false.<br><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>**</strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong>/<br>function isBetween (val, lo, hi) {<br>if ((val &lt; lo) || (val &gt; hi)) { return(false); }<br>else { return(true); }<br>}</li>
</ul>
<p>/<strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>*</strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></p>
<ul>
<li>FUNCTION: isDate checks a valid date</li>
<li>PARAMETERS: theStr AS String</li>
<li>CALLS: isBetween, isInt</li>
<li>RETURNS: TRUE if theStr is a valid date otherwise false.<br><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>**</strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong>/<br>function isDate (theStr) {<br>var the1st = theStr.indexOf(‘-‘);<br>var the2nd = theStr.lastIndexOf(‘-‘);</li>
</ul>
<p>if (the1st == the2nd) { return(false); }<br>else {<br>var y = theStr.substring(0,the1st);<br>var m = theStr.substring(the1st+1,the2nd);<br>var d = theStr.substring(the2nd+1,theStr.length);<br>var maxDays = 31;</p>
<p>if (isInt(m)==false || isInt(d)==false || isInt(y)==false) {<br>return(false); }<br>else if (y.length &lt; 4) { return(false); }<br>else if (!isBetween (m, 1, 12)) { return(false); }<br>else if (m==4 || m==6 || m==9 || m==11) maxDays = 30;<br>else if (m==2) {<br>if (y % 4 &gt; 0) maxDays = 28;<br>else if (y % 100 == 0 &amp;&amp; y % 400 &gt; 0) maxDays = 28;<br>else maxDays = 29;<br>}<br>if (isBetween(d, 1, maxDays) == false) { return(false); }<br>else { return(true); }<br>}<br>}<br>/<strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>*</strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></p>
<ul>
<li>FUNCTION: isEuDate checks a valid date in British format</li>
<li>PARAMETERS: theStr AS String</li>
<li>CALLS: isBetween, isInt</li>
<li>RETURNS: TRUE if theStr is a valid date otherwise false.<br><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>**</strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong>/<br>function isEuDate (theStr) {<br>if (isBetween(theStr.length, 8, 10) == false) { return(false); }<br>else {<br>var the1st = theStr.indexOf(‘/‘);<br>var the2nd = theStr.lastIndexOf(‘/‘);</li>
</ul>
<p>if (the1st == the2nd) { return(false); }<br>else {<br>var m = theStr.substring(the1st+1,the2nd);<br>var d = theStr.substring(0,the1st);<br>var y = theStr.substring(the2nd+1,theStr.length);<br>var maxDays = 31;</p>
<p>if (isInt(m)==false || isInt(d)==false || isInt(y)==false) {<br>return(false); }<br>else if (y.length &lt; 4) { return(false); }<br>else if (isBetween (m, 1, 12) == false) { return(false); }<br>else if (m==4 || m==6 || m==9 || m==11) maxDays = 30;<br>else if (m==2) {<br>if (y % 4 &gt; 0) maxDays = 28;<br>else if (y % 100 == 0 &amp;&amp; y % 400 &gt; 0) maxDays = 28;<br>else maxDays = 29;<br>}</p>
<p>if (isBetween(d, 1, maxDays) == false) { return(false); }<br>else { return(true); }<br>}<br>}</p>
<p>}<br>/<strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><em>**</em></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></p>
<ul>
<li>FUNCTION: Compare Date! Which is the latest!</li>
<li>PARAMETERS: lessDate,moreDate AS String</li>
<li>CALLS: isDate,isBetween</li>
<li>RETURNS: TRUE if lessDate<moredate *********************************************************************************="" function="" iscomdate="" (lessdate="" ,="" moredate)="" {="" if="" (!isdate(lessdate))="" return(false);}="" (!isdate(moredate))="" var="" less1st="lessDate.indexOf('-');" less2nd="lessDate.lastIndexOf('-');" more1st="moreDate.indexOf('-');" more2nd="moreDate.lastIndexOf('-');" lessy="lessDate.substring(0,less1st);" lessm="lessDate.substring(less1st+1,less2nd);" lessd="lessDate.substring(less2nd+1,lessDate.length);" morey="moreDate.substring(0,more1st);" morem="moreDate.substring(more1st+1,more2nd);" mored="moreDate.substring(more2nd+1,moreDate.length);" date1="new" date(lessy,lessm,lessd);="" date2="new" date(morey,morem,mored);="" (date1="">Date2) { return(false);}<br>return(true);</moredate></li>
</ul>
<p>}</p>
<p>/<strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>*</strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></p>
<ul>
<li>FUNCTION isEmpty checks if the parameter is empty or null</li>
<li>PARAMETER str AS String<br><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>**</strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong>/<br>function isEmpty (str) {<br>if ((str==null)||(str.length==0)) return true;<br>else return(false);<br>}</li>
</ul>
<p>/<strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>*</strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></p>
<ul>
<li>FUNCTION: isInt</li>
<li>PARAMETER: theStr AS String </li>
<li>RETURNS: TRUE if the passed parameter is an integer, otherwise FALSE</li>
<li>CALLS: isDigit<br><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>**</strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong>/<br>function isInt (theStr) {<br>var flag = true;</li>
</ul>
<p>if (isEmpty(theStr)) { flag=false; }<br>else<br>{ for (var i=0; i&lt;theStr.length; i++) {<br>if (isDigit(theStr.substring(i,i+1)) == false) {<br>flag = false; break;<br>}<br>}<br>}<br>return(flag);<br>}</p>
<p>/<strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>*</strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></p>
<ul>
<li>FUNCTION: isReal</li>
<li>PARAMETER: heStr AS String<br>decLen AS Integer (how many digits after period)</li>
<li>RETURNS: TRUE if theStr is a float, otherwise FALSE</li>
<li>CALLS: isInt<br><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>**</strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong>/<br>function isReal (theStr, decLen) {<br>var dot1st = theStr.indexOf(‘.’);<br>var dot2nd = theStr.lastIndexOf(‘.’);<br>var OK = true;</li>
</ul>
<p>if (isEmpty(theStr)) return false;</p>
<p>if (dot1st == -1) {<br>if (!isInt(theStr)) return(false);<br>else return(true);<br>}</p>
<p>else if (dot1st != dot2nd) return (false);<br>else if (dot1st==0) return (false);<br>else {<br>var intPart = theStr.substring(0, dot1st);<br>var decPart = theStr.substring(dot2nd+1);</p>
<p>if (decPart.length &gt; decLen) return(false);<br>else if (!isInt(intPart) || !isInt(decPart)) return (false);<br>else if (isEmpty(decPart)) return (false);<br>else return(true);<br>}<br>}</p>
<p>/<strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>*</strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></p>
<ul>
<li>FUNCTION: isEmail</li>
<li>PARAMETER: String (Email Address)</li>
<li>RETURNS: TRUE if the String is a valid Email address</li>
<li>FALSE if the passed string is not a valid Email Address</li>
<li>EMAIL FORMAT: AnyName@EmailServer e.g; webmaster@hotmail.com</li>
<li>@ sign can appear only once in the email address.<br><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>*</strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong>/<br>function isEmail (theStr) {<br>var atIndex = theStr.indexOf(‘@’);<br>var dotIndex = theStr.indexOf(‘.’, atIndex);<br>var flag = true;<br>theSub = theStr.substring(0, dotIndex+1)</li>
</ul>
<p>if ((atIndex &lt; 1)||(atIndex != theStr.lastIndexOf(‘@’))||(dotIndex &lt; atIndex + 2)||(theStr.length &lt;= theSub.length))<br>{ return(false); }<br>else { return(true); }<br>}<br>/<strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>*</strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></p>
<ul>
<li>FUNCTION: newWindow</li>
<li>PARAMETERS: doc -&gt; Document to open in the new window<br>hite -&gt; Height of the new window<br>wide -&gt; Width of the new window<br>bars -&gt; 1-Scroll bars = YES 0-Scroll Bars = NO<br>resize -&gt; 1-Resizable = YES 0-Resizable = NO</li>
<li>CALLS: NONE</li>
<li>RETURNS: New window instance<br><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>**</strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong>/<br>function newWindow (doc, hite, wide, bars, resize) {<br>var winNew=”_blank”;<br>var opt=”toolbar=0,location=0,directories=0,status=0,menubar=0,”;<br>opt+=(“scrollbars=”+bars+”,”);<br>opt+=(“resizable=”+resize+”,”);<br>opt+=(“width=”+wide+”,”);<br>opt+=(“height=”+hite);<br>winHandle=window.open(doc,winNew,opt);<br>return;<br>}<br>/<strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>*</strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></li>
<li>FUNCTION: DecimalFormat</li>
<li>PARAMETERS: paramValue -&gt; Field value</li>
<li>CALLS: NONE</li>
<li>RETURNS: Formated string<br><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>**</strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong>/<br>function DecimalFormat (paramValue) {<br>var intPart = parseInt(paramValue);<br>var decPart =parseFloat(paramValue) - intPart;</li>
</ul>
<p>str = “”;<br>if ((decPart == 0) || (decPart == null)) str += (intPart + “.00”);<br>else str += (intPart + decPart);</p>
<p>return (str);<br>}</p>
<p>“^\d+$”　　//非负整数（正整数 + 0）<br>“^[0-9]<em>[1-9][0-9]</em>$”　　//正整数<br>“^((-\d+)|(0+))$”　　//非正整数（负整数 + 0）<br>“^-[0-9]<em>[1-9][0-9]</em>$”　　//负整数<br>“^-?\d+$”　　　　//整数<br>“^\d+(\.\d+)?$”　　//非负浮点数（正浮点数 + 0）<br>“^(([0-9]+\.[0-9]<em>[1-9][0-9]</em>)|([0-9]<em>[1-9][0-9]</em>\.[0-9]+)|([0-9]<em>[1-9][0-9]</em>))$”　　//正浮点数<br>“^((-\d+(\.\d+)?)|(0+(\.0+)?))$”　　//非正浮点数（负浮点数 + 0）<br>“^(-(([0-9]+\.[0-9]<em>[1-9][0-9]</em>)|([0-9]<em>[1-9][0-9]</em>\.[0-9]+)|([0-9]<em>[1-9][0-9]</em>)))$”　　//负浮点数<br>“^(-?\d+)(\.\d+)?$”　　//浮点数<br>“^[A-Za-z]+$”　　//由26个英文字母组成的字符串<br>“^[A-Z]+$”　　//由26个英文字母的大写组成的字符串<br>“^[a-z]+$”　　//由26个英文字母的小写组成的字符串<br>“^[A-Za-z0-9]+$”　　//由数字和26个英文字母组成的字符串<br>“^\w+$”　　//由数字、26个英文字母或者下划线组成的字符串<br>“^[\w-]+(\.[\w-]+)<em>@[\w-]+(\.[\w-]+)+$”　　　　//email地址<br>“^[a-zA-z]+://(\w+(-\w+)</em>)(\.(\w+(-\w+)<em>))</em>(\?\S*)?$”　　//url<br><a href="http://www.cnblogs.com/light169/archive/2006/10/18/532347.html" target="_blank" rel="external">收藏地址</a></p>

      
    </div>

    <div>
      
        
      
    </div>

    <div>
      
        
  <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
    <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
    <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
      <span>赏</span>
    </button>
    <div id="QR" style="display: none;">
      
        <div id="wechat" style="display: inline-block">
          <img id="wechat_qr" src="/uploads/wechatpay.jpg" alt="YangJ WeChat Pay"/>
          <p>微信打赏</p>
        </div>
      
      
    </div>
  </div>


      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/正则/" rel="tag">#正则</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/20151027/笔记总结(一)/" rel="next" title="笔记总结(一)">
                <i class="fa fa-chevron-left"></i> 笔记总结(一)
              </a>
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/20160121/防淘宝UED相册(可放大图)/" rel="prev" title="防淘宝UED相册(可放大图)">
                防淘宝UED相册(可放大图) <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        <!-- JiaThis Button BEGIN -->
<div class="jiathis_style">
  <a class="jiathis_button_tsina"></a>
  <a class="jiathis_button_tqq"></a>
  <a class="jiathis_button_weixin"></a>
  <a class="jiathis_button_cqq"></a>
  <a class="jiathis_button_douban"></a>
  <a class="jiathis_button_renren"></a>
  <a class="jiathis_button_qzone"></a>
  <a class="jiathis_button_kaixin001"></a>
  <a class="jiathis_button_copy"></a>
  <a href="http://www.jiathis.com/share" class="jiathis jiathis_txt jiathis_separator jtico jtico_jiathis" target="_blank"></a>
  <a class="jiathis_counter_style"></a>
</div>
<script type="text/javascript" >
  var jiathis_config={
    hideMore:false
  }
</script>
<script type="text/javascript" src="http://v3.jiathis.com/code/jia.js" charset="utf-8"></script>
<!-- JiaThis Button END -->

      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="20151028/正则笔记/"
           data-title="正则笔记" data-url="http://YoungHearts.oschina.io/20151028/正则笔记/">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/uploads/avatar.jpg"
               alt="YangJ" />
          <p class="site-author-name" itemprop="name">YangJ</p>
          <p class="site-description motion-element" itemprop="description">欢迎访问我的个人网站，望大家互相交流学习，有问题可在文章下方留言。</p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">13</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">10</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/YoungHearts" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="uploads/FullSizeRender.jpg" target="_blank" title="微信">
                  
                    <i class="fa fa-fw fa-weixin"></i>
                  
                  微信
                </a>
              </span>
            
          
        </div>

        
        

        
        

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-4"><a class="nav-link" href="#0-正则实例通俗说明"><span class="nav-number">1.</span> <span class="nav-text">0. 正则实例通俗说明</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#1-exec-正则通用匹配公式"><span class="nav-number">2.</span> <span class="nav-text">1. exec() 正则通用匹配公式</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2-匹配N个x后的所有字符"><span class="nav-number">3.</span> <span class="nav-text">2. 匹配N个x后的所有字符</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3、其他收藏备份"><span class="nav-number">4.</span> <span class="nav-text">3、其他收藏备份</span></a></li></ol></div>
            
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2015 - 
  <span itemprop="copyrightYear">2016</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">YangJ</span>
</div>

<div class="powered-by">
  powered-by <a class="theme-link" href="http://hexo.io">Hexo</a>
</div>

<div class="theme-info">
  Tm -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>

        

<div class="busuanzi-count">

  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv"><i class="fa fa-user"></i><span class="busuanzi-value" id="busuanzi_value_site_uv"></span></span>
  

  
    <span class="site-pv"><i class="fa fa-eye"></i><span class="busuanzi-value" id="busuanzi_value_site_pv"></span></span>
  
  
</div>



        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/vendors/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/vendors/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/vendors/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.1"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.0.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.0.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.1"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"yangjos"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
      
      <script src="/vendors/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
      <script src="/js/src/hook-duoshuo.js"></script>
    
  






  
  
  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length == 0) {
       search_path = "search.xml";
    }
    var path = "/" + search_path;
    // monitor main search box;

    function proceedsearch() {
      $("body").append('<div class="popoverlay">').css('overflow', 'hidden');
      $('.popup').toggle();

    }
    // search function;
    var searchFunc = function(path, search_id, content_id) {
    'use strict';
    $.ajax({
        url: path,
        dataType: "xml",
        async: true,
        success: function( xmlResponse ) {
            // get the contents from search data
            isfetched = true;
            $('.popup').detach().appendTo('.header-inner');
            var datas = $( "entry", xmlResponse ).map(function() {
                return {
                    title: $( "title", this ).text(),
                    content: $("content",this).text(),
                    url: $( "url" , this).text()
                };
            }).get();
            var $input = document.getElementById(search_id);
            var $resultContent = document.getElementById(content_id);
            $input.addEventListener('input', function(){
                var matchcounts = 0;
                var str='<ul class=\"search-result-list\">';                
                var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                $resultContent.innerHTML = "";
                if (this.value.trim().length > 1) {
                // perform local searching
                datas.forEach(function(data) {
                    var isMatch = true;
                    var content_index = [];
                    var data_title = data.title.trim().toLowerCase();
                    var data_content = data.content.trim().replace(/<[^>]+>/g,"").toLowerCase();
                    var data_url = data.url;
                    var index_title = -1;
                    var index_content = -1;
                    var first_occur = -1;
                    // only match artiles with not empty titles and contents
                    if(data_title != '' && data_content != '') {
                        keywords.forEach(function(keyword, i) {
                            index_title = data_title.indexOf(keyword);
                            index_content = data_content.indexOf(keyword);
                            if( index_title < 0 && index_content < 0 ){
                                isMatch = false;
                            } else {
                                if (index_content < 0) {
                                    index_content = 0;
                                }
                                if (i == 0) {
                                    first_occur = index_content;
                                }
                            }
                        });
                    }
                    // show search results
                    if (isMatch) {
                        matchcounts += 1;
                        str += "<li><a href='"+ data_url +"' class='search-result-title'>"+ data_title +"</a>";
                        var content = data.content.trim().replace(/<[^>]+>/g,"");
                        if (first_occur >= 0) {
                            // cut out 100 characters
                            var start = first_occur - 20;
                            var end = first_occur + 80;
                            if(start < 0){
                                start = 0;
                            }
                            if(start == 0){
                                end = 50;
                            }
                            if(end > content.length){
                                end = content.length;
                            }
                            var match_content = content.substring(start, end);
                            // highlight all keywords
                            keywords.forEach(function(keyword){
                                var regS = new RegExp(keyword, "gi");
                                match_content = match_content.replace(regS, "<b class=\"search-keyword\">"+keyword+"</b>");
                            });
                            
                            str += "<p class=\"search-result\">" + match_content +"...</p>"
                        }
                        str += "</li>";
                    }
                })};
                str += "</ul>";
                if (matchcounts == 0) { str = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>' }
                if (keywords == "") { str = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>' }
                $resultContent.innerHTML = str;
            });
            proceedsearch();
        }
    });}

    // handle and trigger popup window;
    $('.popup-trigger').mousedown(function(e) {
      e.stopPropagation();
      if (isfetched == false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };

    });

    $('.popup-btn-close').click(function(e){
      $('.popup').hide();
      $(".popoverlay").remove();
      $('body').css('overflow', '');
    });
    $('.popup').click(function(e){
      e.stopPropagation();
    });
  </script>

  

  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"></script>
  <script>AV.initialize("0LW1BYEc5igbSTxyRLe6JS8n-gzGzoHsz", "vFsj134Nzu8lKK1s1kLPs4y3");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  
<script type="text/javascript" async src="//push.zhanzhang.baidu.com/push.js">
</script>


</body>
</html>
